package com.zhu.gmallpublisher.utils;


import org.apache.commons.lang3.StringUtils;

import java.util.Collection;
import java.util.Collections;
import java.util.Set;

/**
 * 查询结果封装标准的Sugar数据格式
 */
public class GMVJsonUtil {

    //GMV模块
    public static String getGMVJson(Double gmv) {

        return "{\n" +
                "  \"status\": 0,\n" +
                "  \"msg\": \"\",\n" +
                "  \"data\": " + gmv + "" +
                "}";

    }

    //渠道日活
    public static String getUvByChJson(Set keys, Collection values) {

        return "{\n" +
                "  \"status\": 0,\n" +
                "  \"msg\": \"\",\n" +
                "  \"data\": {\n" +
                "    \"categories\": [\"" +
                StringUtils.join(keys,"\",\"") +
                "\"],\n" +
                "    \"series\": [\n" +
                "      {\n" +
                "        \"name\": \"用户渠道\",\n" +
                "        \"data\": [\n" +
                StringUtils.join(values,",") +
                "]\n" +
                "      }\n" +
                "    ]\n" +
                "  }\n" +
                "}";
    }

    //渠道教交易域 通用
    public static String trafficStatsToJson(Set keys, Collections values){

        return "{\n" +
                "  \"status\": 0,\n" +
                "  \"msg\": \"\",\n" +
                "  \"data\": {\n" +
                "    \"categories\": [\"" +
                StringUtils.join(keys,"\",\"") +
                "\"],\n" +
                "    \"series\": [\n" +
                "      {\n" +
                "        \"name\": \"用户渠道\",\n" +
                "        \"data\": [\n" +
                StringUtils.join(values,",") +
                "]\n" +
                "      }\n" +
                "    ]\n" +
                "  }\n" +
                "}";
    }
}